﻿using System;
using System.Collections.Generic;
using System.Linq;

using SharedGenomics.Domain;
using SharedGenomics.Domain.Builders;
using SharedGenomics.Workbench.PresentationModel;
using SharedGenomics.Workbench.Views;

namespace SharedGenomics.Workbench.Presenters
{
    public class ModelJobOptionsPresenter : Presenter, IJobOptionsPresenter
    {
        private ModelOptionsPTO _pto;

        public ModelJobOptionsPresenter(IModelJobOptionsView view)
            : base(view)
        {
            this._pto = new ModelOptionsPTO { Allelic = true };
            view.PTO = this._pto;
        }

        public bool Validate()
        {
            return this._pto.Validate();
        }

        public JobInfo CreateJob()
        {
            return JobBuilder.NewJob(JobType.PModel)
                .ForDataSet(this.PresentationModel.SelectedDataSetId.Value)
                .WithDescription(this.PresentationModel.Description)
                .WithPermutations(this.PresentationModel.SelectedPermutationCount.Value)
                .WithOptions(this._pto.SelectedModelOptions)
                .ToAnalyse(this.PresentationModel.SelectedPhenotype)
                .Build();
        }

        public JobSubmissionPTO PresentationModel { private get; set; }
    }
}
